package extenddemo;

/**
 * Created by fanshaohua on 2017/11/5.
 */
public class RichSon extends RichFather { //飙红后说明被继承的内容缺少一个默认构造器

    //构造器调用链，在子类继承父类时，会默认调用父类构造器

    public RichSon(){
        super();  //超类，调用父类构造器

        System.out.println("儿子默认构造器");
    }

    public  RichSon(String money, String paoniu){
        super(money);
        System.out.println("儿子有參构造器");
        this.paoniu = paoniu;
    }

    private String paoniu;

    public String getPaoniu() {
        return paoniu;
    }

    public void setPaoniu(String paoniu) {
        this.paoniu = paoniu;
    }

    public void spendMoney(){

        System.out.println("我会花钱");
    }

    @Override  //注解，方法复写，将父类的覆盖
    public void fancyCar() {
        System.out.println("儿子开法拉利");
    }

    @Override
    public String toString() {
        return "RichSon{" +
                "paoniu='" + paoniu + '\'' +
                '}';
    }
}
